﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Boggle
{
    /// <summary>
    /// Simple window to display all words and those that the player has found.
    /// 
    /// Author: Robert Husfeldt
    /// 
    /// </summary>
    public partial class AllWords : Form
    {
        List<string> playerFound;
        List<string> allWords;


        /// <summary>
        /// Creates a window that will display all the words of the current game. Any found
        /// by player will be marked as such (via finalWindow() method) and they can simply exit
        /// when they're done.
        /// </summary>
        /// <param name="sortedsolution">Pass the boggleWindow's sortedsolution for marking what player has gotten</param>
        /// <param name="allWords">What should be created by the DFS solver should be passed here, a list of all words possible in this game.</param>
        public AllWords(List<string> sortedsolution, List<string> allWords)
        {
            InitializeComponent();
            playerFound = sortedsolution;
            this.allWords = allWords;
            allWordsTextBox.Lines = finalWindow();

        }

        /// <summary>
        /// Will fill the AllWords window's textbox with all possible solutions
        /// (as passed into it) and mark any found by player as *Found!* so they can
        /// feel good about themselves.
        /// </summary>
        /// <returns>Final string[] that will fill the textbox.</returns>
        private string[] finalWindow()
        {
            string[] textBoxContents = new string[allWords.Count];

            for (int x = 0; x < allWords.Count; x++)
            {
                if (playerFound.Contains(allWords[x]))
                {
                    allWords[x] += " *Found!*";
                }

                textBoxContents[x] = allWords[x];
            }

            return textBoxContents;
        }

        /// <summary>
        /// Exit the window when the player has seen their fill. I suppose they could then cheat
        /// but that's on them isn't it?
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DoneButton_Click(object sender, EventArgs e)
        {
            Dispose();
        }
    }
}
